package in.unlocker.apps.unlock.mail;

import java.util.Map;

import org.apache.commons.lang3.text.StrSubstitutor;

public class EmailTemplates
{

	private static String registrationTemplate = "Dear User, \n Your  registration with "
			+ "Unlocker application is complete. \n Here are your login details:\n" + "username:  ${username} \n"
			+ "Password:  ${password} \n"
			+ "We need you verify your email address by clicking the following link \n"
			+ "${hostName}/register/verify?id=${idKey}&secret=${emailKey}"
			+ "\nThank you for registering with our site, Please verify your email address  and start using our website\n"
			+ "\nRegards, \n" + "${adminUser}\n" + "${productName}\n" + "${hostName}";

	private static String forgotPasswordTemplate = "Dear ${firstName}, \n We have received your forgot password request."
			+ " \n Here are your login details:\n"
			+ "Username:  ${username} \n"
			+ "Password:  ${password} \n"
			+ "\nRegards, \n" + "${adminUser}\n" + "${productName}\n" + "${hostName}";

		private static String campaignRegisteredTemplate = "Dear ${firstName}, \n A new Campaign has been created successfully in ${productName}. We thank you for bringing this requirement to our notice."
			+ "How ever, there will be  verification followed by approval process, before activating this campaign. You can view the details and status at:\n"
			+ " ${hostName}/campaign/${id}\n"
			+ "\n Thank you for your campaign creation." +
			"\nRegards, \n" + "${adminUser}\n" + "${productName}\n" + "${hostName}";

	private static String campaignForApprovalTemplate = "Dear ${firstName}, \n A new Campaign has been created in ${productName}. Since you are an approver for this type of campaign, We request you to kindly login to the application and confirm your decision."
			+ "You can view the details and take action at ${hostName}/campaign/${id}\n"
			+ "\nRegards, \n" + "${adminUser}\n" + "${productName}\n" + "${hostName}";

	public static final String firstName = "firstName";
	public static final String userName = "username";
	public static final String password = "password";
	public static final String activationCode = "activationCode";
	public static final String caseDescription = "caseDescription";
	public static final String fundReceiptId = "id";
	public static final String adminUser = "adminUser";
	public static final String productName = "productName";
	public static final String hostName = "hostName";
	public static final String amount = "amount";
	public static final String caseId = "id";

	public static String getEmailMessage(Template template, Map<String, String> valuesMap)
	{

		
		//Registration, ForgotPassword, JobPostRegistered, JobPostForApproval, JobApproved, JobApplicationAdded
		StrSubstitutor sub = new StrSubstitutor(valuesMap);
		String resolvedString = null;
		switch (template) {
		case Registration:
			resolvedString = sub.replace(registrationTemplate);
			break;
		case ForgotPassword:
			resolvedString = sub.replace(forgotPasswordTemplate);
			break;
		case campaignRegistered:
			resolvedString = sub.replace(campaignRegisteredTemplate);
			break;
		case campaignForApproval:
			resolvedString = sub.replace(campaignForApprovalTemplate);
			break;
		default:
			// Unsupported template
		}

		return resolvedString;

	}

}
